using System;
using System.Data;
using System.Drawing;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Northwind.Domain.Entities;

namespace Northwind.Web.Controls
{
    public partial class MasterDetailControl : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            grid.DataSource = Category.Broker.GetAll();
            grid.DataBind();
        }

        protected void grid_OnRowCommand(object s, System.Web.UI.WebControls.GridViewCommandEventArgs e)
        {
            int index = int.Parse(e.CommandArgument.ToString());

            int id = int.Parse(grid.Rows[index].Cells[1].Text);

            grid.Rows[index].BackColor = Color.Honeydew;

            Category category = Category.Broker.GetByID(id);
            
            detailPanel.Visible = true;

            idLabel.Text = category.CategoryID.ToString();
            nameLabel.Text = category.CategoryName;
            descriptionLabel.Text = category.Description;            
        }
    }
}